package Tests;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import Accounts.Bank;
import Accounts.CheckingAccount;

public class BankTest {

	private Bank bank;
	public BankTest()
	{
		testBank();
		testOpenSimpleCheckingAccount();
		testOpenFullPackage();
		testWithdrawMoney();
	}
	@Test
	public void testBank() 
	{		
		bank = new Bank("Melaku");
		assertNotNull("The bank object is null", bank);
	}

	@Test
	public void testOpenSimpleCheckingAccount() 
	{
		bank = new Bank("Melaku");
		//open a simple checking account 
		int accountNum1 = bank.openSimpleCheckingAccount();
		int accountNum2 = bank.openSimpleCheckingAccount();
		//when you create a checking account for the first time, 
		//account number should be 0
		assertEquals("Expected vs actual",0, accountNum1);
		//when you create a checking account for the first time, 
		//account number should be 1
		assertEquals("Expected vs actual",1, accountNum2);
	}

	@Test
	public void testOpenFullPackage() 
	{
		bank = new Bank("Melaku");
		/*when you create a full package, the account number should 
		  be 2 since we have already created 2 accounts with
		  account number 0 and 1 in testOpenSimpleCheckingAccount() method.  
		*/
		int accountNum = bank.openFullPackage();
		assertEquals("Expected vs actual",2, accountNum);

	}

	@Test
	public void testWithdrawMoney() 
	{
		//the withdrawMoney() method creates an account by passing 
		//an account number and the default balance is 0. 
		bank = new Bank("Melaku");
		int acc = bank.openSimpleCheckingAccount();
		boolean success = bank.withdrawMoney(acc, 100);
		//we can't draw $100.00 while our balance is really 0.
		assertFalse("withdraw money is not a success!", success);
		
	}

}
